﻿namespace = jewish_events

### Rabbinic priesthood wants to become monogamous

jewish_events.0001 = {
	type = character_event
	title = jewish_events.0001.t
	desc = jewish_events.0001.desc
	theme = learning

	left_portrait = {
		character = root
		animation = personality_bold
	}

	option = { #Just accept it
		name = jewish_events.0001.a
		show_as_tooltip = {
			root.faith = {
				remove_doctrine = var:faith_polygamy_doctrine
				add_doctrine = doctrine_monogamy
				if = {
					limit = {
						var:faith_swap_realm_celebration = yes
					}
					remove_doctrine = doctrine_marriage_realm_celebration_disallowed
					add_doctrine = doctrine_marriage_realm_celebration_first
				}
			}
		}
		ai_chance = {
			base = 100
		}
	}

	option = { #Refuse to change - Polygamy
		name = jewish_events.0001.b
		trigger = {
			root.faith = {
				has_doctrine_parameter = allows_polygamy
				NOT = { has_doctrine_parameter = allows_concubinage }
			}
			this = root.culture.culture_head
			root.culture = {
				NOR = {
					has_cultural_parameter = allows_polygamy
					has_cultural_parameter = allows_concubinage
					has_cultural_tradition = tradition_monogamous
				}
			}
		}
		add_piety = major_piety_loss
		show_as_tooltip = {
			root.faith = {
				remove_doctrine = var:faith_polygamy_doctrine
				add_doctrine = doctrine_monogamy
				if = {
					limit = {
						var:faith_swap_realm_celebration = yes
					}
					remove_doctrine = doctrine_marriage_realm_celebration_disallowed
					add_doctrine = doctrine_marriage_realm_celebration_first
					
				}
			}
		}
		root.culture = {
			add_culture_tradition = tradition_polygamous
		}
	}

	option = { #Refuse to change - Harem
		name = jewish_events.0001.b
		trigger = {
			root.faith = {
				has_doctrine_parameter = allows_polygamy
				has_doctrine_parameter = allows_concubinage
			}
			this = root.culture.culture_head
			root.culture = {
				NOR = {
					has_cultural_parameter = allows_polygamy
					has_cultural_parameter = allows_concubinage
					has_cultural_tradition = tradition_monogamous
				}
			}
		}
		add_piety = major_piety_loss
		show_as_tooltip = {
			root.faith = {
				remove_doctrine = var:faith_polygamy_doctrine
				add_doctrine = doctrine_monogamy
				if = {
					limit = {
						var:faith_swap_realm_celebration = yes
					}
					remove_doctrine = doctrine_marriage_realm_celebration_disallowed
					add_doctrine = doctrine_marriage_realm_celebration_first
					
				}
			}
		}
		root.culture = {
			add_culture_tradition = tradition_harem
		}
	}

	option = { #Refuse to change but also you're powerful enough to supercede the priesthood
		name = jewish_events.0001.c
		trigger = {
			exists = root.faith.religious_head
			root.faith.religious_head = { is_vassal_or_below_of = root }
		}
		add_piety_level = -1
		reverse_add_opinion = {
			target = root.faith.religious_head
        	modifier = insulted_opinion
        	opinion = -75
		}
		root.faith = {
			set_variable = {
				name = rabbinicism_rejected_monogamy
				value = yes
			}
		}
	}

	after = {
		hidden_effect = {
			add_character_flag = had_event_jewish_events_0001
			if = {
				limit = {
					NOT = { root.faith = { has_variable = rabbinicism_rejected_monogamy } }
				}
				if = {
					limit = {
						root.faith = { has_doctrine_parameter = allows_polygamy }
					}
					root.faith = {
						set_variable = {
							name = rabbinicism_accepted_monogamy
							value = yes
						}
						remove_doctrine = var:faith_polygamy_doctrine
						add_doctrine = doctrine_monogamy
						if = {
							limit = {
								var:faith_swap_realm_celebration = yes
							}
							remove_doctrine = doctrine_marriage_realm_celebration_disallowed
							add_doctrine = doctrine_marriage_realm_celebration_first
							
						}
					}
				}
				if = {
					limit = {
						exists = root.faith.religious_head
						root.faith.religious_head = { is_vassal_or_below_of = root }
					}
					every_player = {
						limit = {
							faith = root.faith
							NOT = { has_character_flag = had_event_jewish_events_0001 }
						}
						trigger_event = jewish_events.0001
					}
				}
			}
		}
	}
}